<?php
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
include "../../operations/connection_ajax.php";
if ( !isset($_GET['pages'] ))
	{
    	$page = 1 ;
	}else{
		$page = $_GET['pages'] ;
}

$rows_per_page = 20;
$page_start = ( $page - 1 ) * $rows_per_page; 
$page_end = $page * $rows_per_page;

if (isset($_REQUEST['ids'])) {
	mysql_query("delete from request_password where ID = ".$_REQUEST['ids']);
}
	
$listpassrequest = mysql_query("select ID, Username, Email, `Comment`, CreatedDate, `Status` from request_password order by CreatedDate desc limit ".$page_start.",".$rows_per_page);
$listpassrequestPage = mysql_query("select ID from request_password order by CreatedDate desc ");


$number_of_page = ceil ( mysql_num_rows( $listpassrequestPage ) / $rows_per_page );

				 
					$i_reps = 1;
					while ($row = mysql_fetch_array($listpassrequest)) {
						
					?>
					<tr>
						<td class="rf-dt-c" style="font-size: 12px;text-align: center ;" scope="col"><?if ($row[Status]==0) {?>
							<img src ="images/sad.png"/>
						<?php }else{?> <img src ="images/check.png"/><?php }?></td>
						<td class="rf-dt-c" style="font-size: 12px;text-align: center;" scope="col"><?=(($page-1)*$rows_per_page)+$i_reps?></td>
						<td class="rf-dt-c" style="font-size: 12px;text-align: center;" scope="col"><?=$row[Username]?></td>
						<td class="rf-dt-c" style="font-size: 12px;text-align: center;" scope="col"><?=$row[Email]?></td>
						<td class="rf-dt-c" style="font-size: 12px;text-align: center;" scope="col"><?=$row[CreatedDate]?></td>
						<td class="rf-dt-c" style="font-size: 12px;text-align: center;" scope="col">
						<input id="reset" name="reset" onclick="resetrequest(<?=$page?>,<?=$row[ID]?>,this)" value="<?echo 'Reset'?>" <?if ($row[Status]==1) {?>
							disabled="disabled"	<?php } ?>
							style="padding: 5px 5px 5px 5px;"
							type="button" />
						<input id="delete" name="delete" onclick="if(confirm('<?php echo $l_confirm_deleteproject?>')){deleterequest(<?=$row[ID]?>)}" value="<?echo $_REQUEST['l_delete'];?>" 
							style="padding: 5px 5px 5px 5px;"
							type="button" />
						</td>
					</tr>
					<?php
					$i_reps +=1;
					}
					?>
					<tr class="trfoot">
	                    	<td class="rf-dt-ftr-c" scope="colgroup" colspan="9">
	                        	<div style="text-align: center; width: 100%">
	                            	<span class="rf-ds">
															
															<?php if ( $number_of_page > 1 ) 
															{ 
																if ($page==1)
																	$p=2;
																else if ($page==$number_of_page)
																	$p=$number_of_page-1;
																else $p=$page;
																if($page!=1){?>
																	<a onclick="paging(1,'')" ><span class='button_next'><?php echo "<<<";?></span> </a>
																	<a onclick="paging(<?=($page-1)?>,'')" ><span class='button_next'><?php echo "<<";?></span> </a>
																<?php  }
																else{
																	echo "<span class='button_next'><<<</span>"; 
																	echo "<span class='button_next'><<</span>";
																}
																for ( $i = $p-1; $i <= $p+1; $i++ ) {	
																		if ($i<=$number_of_page && $i>0)
																		
																			if ($i==$page){
																				echo "<span class='button_next' style='color: #000'><i>".$i."</i></span>"; 
																			}else{
																			?>
																				<a onclick="paging(<?=$i?>,'')" ><span class="button_next">
																				<?php 
																				echo $i;
																				?>
																				</span> </a>
																			<?php 
																			}
																		?>
																	
																<?php 
																		}
																	
																	if($page!=$number_of_page){ ?>
																		<a onclick="paging(<?=($page+1)?>,'')"><span class='button_next'><?php echo ">>";?></span> </a>
																		<a onclick="paging(<?=($number_of_page)?>,'')" ><span class='button_next'><?php echo ">>>";?></span> </a>
																	<?php }
																	else{
																		echo "<span class='button_next'>>></span> ";
																		echo "<span class='button_next'>>>></span> ";
																	}
																}
															
																
																?>
																													
														</span>
														</div>
														</td>
	                    </tr>
	                    
	              <?php mysql_close($connection_ajax);?>